# -*- coding: utf-8 -*-
'''
@time: 2019/2/18 10:44
@author: hyq
@software: PyCharm
@file: test03.py
'''

import paramiko
# 创建SSH对象
ssh = paramiko.SSHClient()
#指定当对方主机没有本机公钥的情况时应该怎么办，AutoAddPolicy表示自动在对方主机保存下本机的秘钥
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# 连接服务器
ssh.connect(hostname='10.150.26.76',port=22,username='fengqichao',password='!dSCnSJBU*670H^P')
# stdout 为正确输出，stderr为错误输出，同时是有1个变量有值
stdin,stdout,stderr = ssh.exec_command("tail -100 /opt/logs/entrust/api/main.log")
result = stdout.read().decode()
# print(result)
print(stderr.read().decode())
ssh.close()